<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
	<% String path=request.getContextPath(); String basePath=request.getScheme() + "://" + request.getServerName() + ":"
		+ request.getServerPort() + path + "/" ; %>

		<!DOCTYPE html>
		<html>

		<head>
			<base href="<%=basePath%>">

			<title>${tableComment}</title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
			<meta http-equiv="description" content="This is my page">
			<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

		</head>

		<body>
			<%@ include file="/WEB-INF/jsp/common/header.jsp" %>

				<script type="text/javascript">
					$(function () {
						bindgrid();
					});
				</script>
				<script>
					function del(node) {
						$.ajax({
							type: "post",
							url: "UserManage/DelUser",
							//                dataType: "xml",
							data: {
								userid: node.userid,
								czr: PUser.loginname
							},
							success: function (data) {
								$.messager.alert('消息', data);
								$('#add').window('close');
								bindgrid();
							},
							error: function (XMLHttpRequest, textStatus, errorThrown) {
								$.messager.alert('消息', errorThrown);
							}
						});
					}

					function save() {
						if (!$('#ssec-form').form('validate')) {
							return;
						}
					}

					function editrow() {
						//编辑用户
						var user = $('#dg').datagrid('getSelected');
						if (user) {
							$('#add').window('open');
							$('#t1').val(user.userid);

						} else {
							$.messager.alert('消息', '请选中一个用户');
						}
					}
				</script>
				<script>
					function bindgrid() {
						$('#dg').datagrid(
							{
								title: '',
								url: 'UserManage/UserListJson?dwbm=' + dept + '&name='
									+ name,
								iconCls: 'icon-application',
								width: 700,
								height: 500,
								nowrap: true,
								rownumbers: true,
								animate: false,
								collapsible: false,
								clientPaging: false,
								remoteFilter: true,
								singleSelect: true,
								remoteSort: true,
								columns: [[{
									field: 'username',
									title: '姓名',
									sortable: true,
									formatter: function (val, rec) {
										return unescape(val)
									}
								},]],
								toolbar: [
									{
										text: '增加',
										iconCls: 'icon-add',
										handler: function () {
											$('#ssec-form').form('clear');
											$('#add').window('open');
										}
									},
									'-',
									{
										text: '编辑',
										iconCls: 'icon-edit',
										handler: function () {
											editrow();
										}
									},
									'-',
									{
										text: '删除',
										iconCls: 'icon-cancel',
										handler: function () {
											var row = $('#dg').datagrid(
												'getSelected');
											if (row) {
												$.messager.confirm('提示', '确定要删除吗?', function (r) {
													if (r) { del(row); }
												});
											}
										}
									}} ],
							onLoadSuccess : function () {
							},
							onDblClickRow : function () {
								editrow();
							}
					});
		} 
				</script>
				<style scoped="scoped">
					.textbox {
						height: 20px;
						margin: 0;
						padding: 0 2px;
						box-sizing: content-box;
					}

					/*.table tr {
        height: 15px;
    }*/
				</style>
				<table id="dg"></table>

				<div id="search" class="easyui-window" closed="true" modal="true" title="用户信息"
					style="width: 500px; height: 300px; padding: 10px 20px">
					<form id="searchform" class="ssec-form">
						<table class="table">
							<tr>
								<td>
									<div class="ssec-label">用户名：</div>
								</td>
								<td>
									<div class="ssec-text normal">
										<input id="searchName" class="easyui-validatebox textbox"
											data-options="required:true" />
									</div>
								</td>
							</tr>
						</table>
						<div style="padding: 5px; text-align: right;">
							<a class="easyui-linkbutton" onclick="searchName();" iconcls="icon-save">查询</a>
						</div>
					</form>
				</div>
				<div id="add" class="easyui-window" closed="true" modal="true" title="用户信息"
					style="width: 500px; height: 450px; padding: 10px 20px">
					<form id="ssec-form" class="ssec-form">
						<table class="table">
							<tr style="display: none;">
								<td>
									<div class="ssec-label" style="display: none;">用户ID：</div>
								</td>
								<td>
									<div class="ssec-text normal" style="display: none;">
										<input id="t1" type="text" />
									</div>
								</td>
							</tr>
							<tr>
								<td>
									<div class="ssec-label">登陆名：</div>
								</td>
								<td>
									<div class="ssec-text normal">
										<input id="t3" class="easyui-validatebox textbox"
											data-options="required:true" />
									</div>
								</td>
							</tr>

						</table>
						<div style="padding: 5px; text-align: right;">
							<a class="easyui-linkbutton" onclick="save();" iconcls="icon-save">保存</a>
						</div>
					</form>
				</div>
		</body>

		</html>